from urllib import request
from fake_useragent import UserAgent
# 设置访问地址
url = "https://httpbin.org/get"

# 重构headers请求的头信息
headers = {
    'User-Agent' : UserAgent().random
}
# 创建请求对象，设置UA
req = request.Request(url=url, headers=headers)
# 发送请求，获取响应
res = request.urlopen(req)
# 获取信息并提取设置格式
html = res.read().decode('utf-8')

print(html)